var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function n() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((n.prototype = i.prototype), new n()));
      };
    })(),
  SendEmailEditView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.emailThingObj = []),
        (t.max = 9999999),
        (t.min = 0),
        (t.step = 1),
        (t.num = 0),
        (t.onLoadMySelfMoneyFn = {
          caller: t,
          code: 1451,
          method: function (e) {
            0 == e.code &&
              ((t.max = parseInt(e.data.money)),
              (t.slider_editEmail.max = t.max),
              (t.text_email_moneyValue.maxChars = t.max));
          },
        }),
        (t.onLoadEditingEmailData = {
          caller: t,
          code: 1025,
          method: function (e) {
            if (0 == e.code) {
              t.list_email_editing.visible = !0;
              var i,
                n = e.data;
              (t.editdataArr = []), (t.emailThingObj = e.data.list);
              for (var a = 0; a < n.list.length; a++)
                (i = {
                  label_editing_name: {
                    text:
                      n.list[a].name +
                      "(" +
                      n.list[a].num +
                      ")个  " +
                      n.list[a].money +
                      "银子",
                  },
                }),
                  t.editdataArr.push(i);
              t.list_email_editing.dataSource = t.editdataArr;
            }
          },
        }),
        (t.onLoadDeleteEmailItemData = {
          caller: t,
          code: 1188,
          method: function (e) {
            WebSocketService.send({ c: 1025, d: null });
          },
        }),
        (t.onLoadSendEmialResultData = {
          caller: t,
          code: 1176,
          method: function (e) {
            0 == e.code
              ? (ToastView.toastView(e.data),
                "send_email_type" == t.tab_type &&
                  WebSocketService.send({
                    c: 1171,
                    d: { type: "2", pageNum: 0 },
                  }),
                (t.text_email_toId.text = ""),
                (t.text_email_moneyValue.text = ""),
                (t.slider_editEmail.value = 0),
                (t.num = 0),
                t.onSendEditCancleFn())
              : ToastView.toastView(e.msg);
          },
        }),
        t.btn_sendEdit_cancle.on(Laya.Event.CLICK, t, t.onSendEditCancleFn),
        t.btn_send_email.on(Laya.Event.CLICK, t, t.onSendEmailEditFn),
        t.btn_email_addGoods.on(Laya.Event.CLICK, t, t.onEmailAddGoodsItemFn),
        WebSocketService.addListener(t.onLoadEditingEmailData, !0),
        WebSocketService.addListener(t.onLoadDeleteEmailItemData, !0),
        WebSocketService.addListener(t.onLoadSendEmialResultData, !0),
        WebSocketService.addListener(t.onLoadMySelfMoneyFn),
        (t.list_email_editing.visible = !1),
        (t.list_email_editing.selectEnable = !0),
        (t.list_email_editing.vScrollBarSkin = ""),
        t.list_email_editing.on(Laya.Event.CLICK, t, t.onEditingEmailAction),
        t.btn_editEmail_dele.on(
          Laya.Event.CLICK,
          t,
          t.onDidClickEditEmailItemFn
        ),
        t.btn_editEmail_plus.on(
          Laya.Event.CLICK,
          t,
          t.onDidClickEditEmailItemFn
        ),
        t.slider_editEmail.on(Laya.Event.CHANGE, t, t.onSliderEditChange),
        t.text_email_moneyValue.on(Laya.Event.FOCUS, t, t.onShowFocus),
        t.text_email_moneyValue.on(Laya.Event.BLUR, t, t.onShowBLUR),
        (t.text_email_moneyValue.restrict = "0-9"),
        t.text_email_moneyValue.on(
          Laya.Event.CLICK,
          t,
          t.onTextEmailValueChangeFn
        ),
        (t.text_email_toId.restrict = "0-9"),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openSendEmailView = function (e, i) {
        null == this.sendEmailVC && (this.sendEmailVC = new t()),
          WebSocketService.send({ c: 1025, d: null }),
          WebSocketService.send({ c: 1451 }),
          (this.sendEmailVC.tab_type = i),
          (this.sendEmailVC.num = 0),
          (this.sendEmailVC.text_email_toId.text = ""),
          e && "" != e && (this.sendEmailVC.text_email_toId.text = e),
          (this.sendEmailVC.slider_editEmail.value = 0),
          (this.sendEmailVC.label_edit_money.text = "0银"),
          (this.sendEmailVC.text_email_moneyValue.text = ""),
          (this.sendEmailVC.num = 0),
          Laya.stage.addChild(this.sendEmailVC);
      }),
      (t.prototype.onShowFocus = function (e) {
        var t = e.textField.text;
        NaN == e.textField.text && (t = 0), (this.slider_editEmail.value = t);
      }),
      (t.prototype.onShowBLUR = function (e) {
        var t = e.textField.text;
        e && NaN == e.textField.text && (t = 0),
          (this.slider_editEmail.value = t);
      }),
      (t.prototype.onTextEmailValueChangeFn = function (e) {}),
      (t.prototype.onDidClickEditEmailItemFn = function (e) {
        "item0" == e.target.name
          ? ((this.num = this.num - this.step),
            this.num < this.min && (this.num = this.min),
            (this.slider_editEmail.value = this.num))
          : "item1" == e.target.name &&
            ((this.num = this.num + this.step),
            this.num > this.max && (this.num = this.max),
            (this.slider_editEmail.value = this.num)),
          (this.label_edit_money.text = this.slider_editEmail.value + "银"),
          (this.text_email_moneyValue.text = this.slider_editEmail.value + "");
      }),
      (t.prototype.onSliderEditChange = function () {
        (this.num = this.slider_editEmail.value),
          (this.label_edit_money.text = this.slider_editEmail.value + "银"),
          (this.text_email_moneyValue.text = this.slider_editEmail.value + "");
      }),
      (t.prototype.onSendEmailEditFn = function () {
        var e = this.text_email_toId.text;
        if (0 != e.split(" ").join("").length) {
          var t = this.text_email_fuyan.text;
          WebSocketService.send({
            c: 1176,
            d: { toId: e, count: this.num, content: t },
          });
        } else ToastView.toastView("请输入需要发邮包的对方ID");
      }),
      (t.prototype.onEditingEmailAction = function (e) {
        if (
          "" != e.target.name &&
          "email_content_delete_button" == e.target.name
        ) {
          var t = this.emailThingObj[this.list_email_editing.selectedIndex];
          WebSocketService.send({
            c: 1188,
            d: { id: t.thingid, t: t.thingtype },
          });
        }
      }),
      (t.prototype.onEmailAddGoodsItemFn = function () {
        SendEmailGoodsDialog.showEmailGoodsView();
      }),
      (t.prototype.onSendEditCancleFn = function () {
        (this.text_email_fuyan.text = ""), this.removeSelf();
      }),
      t
    );
  })(ui.EmailController.SendEmailEditViewUI);
